package org.obm.delivery.cassandra.impl;

import org.apache.james.mime4j.dom.Message;
import org.apache.james.mime4j.dom.address.Address;
import org.apache.james.mime4j.dom.address.AddressList;
import org.apache.james.mime4j.dom.field.Field;

public final class DenormHelper {

	public static String addrList(AddressList al) {
		if (al == null) {
			return "";
		}

		StringBuilder sb = new StringBuilder(al.size() * 50);
		int i = 0;
		for (Address a : al) {
			if (i++ > 0) {
				sb.append(", ");
			}
			sb.append(a.getDisplayString());
		}
		return sb.toString();
	}

	public static final String header(Message m, String h) {
		String body = null;
		Field f = m.getHeader().getField(h);

		if (f != null) {
			body = f.getBody();
		}

		return body;
	}

}
